import pymysql

#创建连接
db=pymysql.connect(
    host='localhost',
    user='root',
    password='123456',
    database='jiangsu',
    port=3306,
   )
try:
    i=1
    with db.cursor() as cursor:
        while i <=10:
            username=input("请输入姓名:")
            age=int(input("请输入年龄:"))
            sex=input("请输入性别：")
            high=float(input("请输入身高:"))
            sql=f"insert into person values('{username}',{age},'{sex}',{high})"
            cursor.execute(sql)
            db.commit()
            print("数据添加成功")
            i+=1
except Exception as e:
    print("数据添加失败",e)
finally:
    db.close()
